package com.luckberry.murder.mapper;

import com.luckberry.murder.entity.Script;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ScriptMapper {

    @Select("select * from script")
    List<Script> getScripts();

    @Select("select * from script where name like '%' #{name} '%'")
    List<Script> getScriptsByName(String name);

    @Select("select * from script where sid = #{sid}")
    Script getScript(int sid);

    @Insert("insert into script(name, type, face, content, price, time, people, star, starPeople, played) VALUES (#{name}, #{type}, #{face}, #{content}, #{price}, #{time}, #{people}, #{star}, #{starPeople}, #{played})")
    int addScript(Script script);

    @Delete("delete script from script where sid = #{sid}")
    int deleteScript(int sid);

    @Update("update script set name = #{name}, type = #{type}, face = #{face}, content = #{content}, price = #{price}, time = #{time}, people = #{people}, star = #{star}, starPeople = #{starPeople}, played = #{played} where sid = #{sid}")
    int editScript(Script script);
}
